You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): setup script output no longer ends in half an emoji - #40701
In apps/server/src/project/ProjectSetupScriptRunner.ts, setup script output lines are capped with cleaned.slice(0, OUTPUT_LINE_MAX_LENGTH) (400 UTF-16 code units) and newline-free output is bounded with lineBuffer.slice(-PARTIAL_LINE_MAX_LENGTH) (4,096 UTF-16 code units). When either cut lands between the two halves of a UTF-16 surrogate pair, a lone surrogate reaches WorktreeSetupTracker.appendTail and shows as a replacement character (U+FFFD) in the worktree setup card.
Change
Both slices now check splitsSurrogatePair from @t3tools/shared/assistantCitations (already used by sibling AgentSessionScanner.ts) and step by one code unit when a cut would split a surrogate pair: the 400-unit line cap stops at 399 before a trailing high surrogate, and the 4,096-unit partial-line tail starts one unit later past a leading low surrogate. Limits, escape stripping, and script execution are unchanged.
This re-lands MarcoDotIO's #32217 (Macroscope-approved, self-closed as cosmetic with no maintainer objection), adapted to reuse splitsSurrogatePair on current main, with him as co-author.
Scope
A very small, focused fix for an obvious bug, so no issue is needed: capping valid terminal output should not leave lone surrogates. Both slices guard the same output line on the same path, so they are one underlying problem. Same bug class as merged #39548 and #29647.
Verification
Added ProjectSetupScriptRunner > keeps emoji whole when capping a long output line or partial-line buffer to apps/server/src/project/ProjectSetupScriptRunner.test.ts, emitting both a 400-unit boundary split (x + 250 🙂 + \r\n) and a 4,096-unit partial-line boundary split (2,100 🙂 + x, then \r\n).
On unmodified upstream/main (c1fbdf6cdb) with only the test added, vp test run apps/server/src/project/ProjectSetupScriptRunner.test.ts fails on the new test because the first line ends with a lone high surrogate (U+D83D) and the second line both starts with a lone low surrogate (U+DE42) and ends with a lone high surrogate (U+D83D).
With the fix, all 12 tests in ProjectSetupScriptRunner pass (including the new regression test) and 4 of 5 tests in POSIX setup completion pass; the one failure is reports a nonzero completion for a syntax error (expected exit code 2, received 1), which fails identically on unmodified upstream/main on this macOS machine because /bin/bash is GNU bash 3.2.57 (where eval "if then" exits 1).
vp fmt --check apps/server/src/project/: all matched files formatted (33 files)
vp run --filter t3 typecheck (effect-tsgo tsrs --noEmit): 0 errors (exit 0)
Not checked: rendering the worktree setup card in a live client on web, desktop, or mobile (server-only change; no contract or client code changed, and the unit test exercises ProjectSetupScriptRunner's onOutputLine output directly). WorktreeSetupTracker.clampText (used for stage details and launch errors) is left out of scope since setup output lines are already bounded to 400 units by the runner.
The 400-unit output line cap and 4,096-unit partial-line tail cap could
cut inside a UTF-16 surrogate pair, leaving a lone surrogate that renders
as a replacement character. Re-lands pingdotgg#32217.
Co-authored-by: MarcoDotIO <20867620+MarcoDotIO@users.noreply.github.com>
Reviewing files that changed from the base of the PR and between 8163983 and 42ebe61.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Setup script output truncation now avoids splitting UTF-16 surrogate pairs in completed lines and oversized partial lines. A test covers long emoji-containing output.
Completed lines reduce the output cap when its boundary splits a surrogate pair. Partial-line truncation advances its start boundary when it splits a pair. A test checks long emoji-containing lines.
pingdotgg/t3code#32217: Changes the same completed-line and partial-line truncation boundaries in ProjectSetupScriptRunner.
Suggested labels:bugfix
Suggested reviewers:macroscopeapp, juliusmarminge
Merge Risk: Minimal · previous review 81639
Setup script output truncation now keeps emoji whole at both length caps. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(server): setup script output no longer ends in half an emoji" matches the main change. The diff caps setup script output lines and partial-line buffers so a UTF-16 surrogate pair is not…
Description check
The description follows the template's sections: Problem, Change, Scope, and Verification. The Problem section explains the lone surrogate bug and the affected slices. The Change section explains the …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(server): setup script output no longer ends in half an emoji" matches the main change. The diff caps setup script output lines and partial-line buffers so a UTF-16 surrogate pair is not split. The title is specific and follows the conventional commit style used in the repository template.
Full details: Description check
Explanation
The description follows the template's sections: Problem, Change, Scope, and Verification. The Problem section explains the lone surrogate bug and the affected slices. The Change section explains the fix and why it reuses splitsSurrogatePair. The Scope section explains why no issue is linked and why the change is small. The Verification section lists focused tests, lint, format, and typecheck results, plus the one failing test and what was not checked. The description does not link a bug issue, but it gives a reason for omitting one, as the template allows for small obvious fixes. The agent attribution line is present at the end.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Created the reported Emoji setup action, imported it through Project actions, and started a new worktree thread. Captured the setup card while the script slept. Both runs used Chromium, 1280×800, light theme, fresh synthetic data, and /bin/sh. Base visibly starts with a replacement glyph and fails the DOM Unicode well-formedness check; head shows whole emoji and passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
apps/server/src/project/ProjectSetupScriptRunner.ts, setup script output lines are capped withcleaned.slice(0, OUTPUT_LINE_MAX_LENGTH)(400 UTF-16 code units) and newline-free output is bounded withlineBuffer.slice(-PARTIAL_LINE_MAX_LENGTH)(4,096 UTF-16 code units). When either cut lands between the two halves of a UTF-16 surrogate pair, a lone surrogate reachesWorktreeSetupTracker.appendTailand shows as a replacement character (U+FFFD) in the worktree setup card.Change
Both slices now check
splitsSurrogatePairfrom@t3tools/shared/assistantCitations(already used by siblingAgentSessionScanner.ts) and step by one code unit when a cut would split a surrogate pair: the 400-unit line cap stops at 399 before a trailing high surrogate, and the 4,096-unit partial-line tail starts one unit later past a leading low surrogate. Limits, escape stripping, and script execution are unchanged.This re-lands MarcoDotIO's #32217 (Macroscope-approved, self-closed as cosmetic with no maintainer objection), adapted to reuse
splitsSurrogatePairon currentmain, with him as co-author.Scope
A very small, focused fix for an obvious bug, so no issue is needed: capping valid terminal output should not leave lone surrogates. Both slices guard the same output line on the same path, so they are one underlying problem. Same bug class as merged #39548 and #29647.
Verification
Added
ProjectSetupScriptRunner > keeps emoji whole when capping a long output line or partial-line buffertoapps/server/src/project/ProjectSetupScriptRunner.test.ts, emitting both a 400-unit boundary split (x+ 250🙂+\r\n) and a 4,096-unit partial-line boundary split (2,100🙂+x, then\r\n).On unmodified
upstream/main(c1fbdf6cdb) with only the test added,vp test run apps/server/src/project/ProjectSetupScriptRunner.test.tsfails on the new test because the first line ends with a lone high surrogate (U+D83D) and the second line both starts with a lone low surrogate (U+DE42) and ends with a lone high surrogate (U+D83D).With the fix, all 12 tests in
ProjectSetupScriptRunnerpass (including the new regression test) and 4 of 5 tests inPOSIX setup completionpass; the one failure isreports a nonzero completion for a syntax error(expected exit code2, received1), which fails identically on unmodifiedupstream/mainon this macOS machine because/bin/bashis GNU bash 3.2.57 (whereeval "if then"exits1).Also ran:
vp lint apps/server/src/project/: 0 warnings, 0 errors (33 files)vp fmt --check apps/server/src/project/: all matched files formatted (33 files)vp run --filter t3 typecheck(effect-tsgo tsrs --noEmit): 0 errors (exit 0)Not checked: rendering the worktree setup card in a live client on web, desktop, or mobile (server-only change; no contract or client code changed, and the unit test exercises
ProjectSetupScriptRunner'sonOutputLineoutput directly).WorktreeSetupTracker.clampText(used for stage details and launch errors) is left out of scope since setup output lines are already bounded to 400 units by the runner.Gemini 4 Neon via T3 Code